<?php
class retrieve_polls_admin extends retrieve_base{

	private $module_display_options 	= array(
		Array("POLLS_DISPLAY","DISPLAY_POLL_CHANNEL_OPEN")
	);

	/**
	* function produces abstract structure of modules db structure
	*
    * used to generate the table structure required abstract function that passes an abstract
	* representation of the desired table structure to the proper database module which will
	* interpet the abstract and convert it into a valid SQL Create table structure.
	*
	* @return Array list of abstract table definitions for this module
	*/
	function create_table(){
		$tables = array();
		/**
		* Table structure for table 'group_data'
		*/
		$fields = array(
			array("poll_list_identifier"			,"unsigned integer"			,"NOT NULL"	,"auto_increment"),
			array("poll_list_client"				,"unsigned integer"			,"NOT NULL"	,"default '0'"),
			array("poll_list_label"					,"varchar(255)"				,"NOT NULL"	,"default ''"),
			array("poll_list_answer1"				,"varchar(255)"				,""			,"default ''"),
			array("poll_list_answer2"				,"varchar(255)"				,""			,"default ''"),
			array("poll_list_answer3"				,"varchar(255)"				,""			,"default ''"),
			array("poll_list_answer4"				,"varchar(255)"				,""			,"default ''"),
			array("poll_list_answer5"				,"varchar(255)"				,""			,"default ''"),
			array("poll_list_answer6"				,"varchar(255)"				,""			,"default ''"),
			array("poll_list_answer7"				,"varchar(255)"				,""			,"default ''"),
			array("poll_list_answer8"				,"varchar(255)"				,""			,"default ''"),
			array("poll_list_answer9"				,"varchar(255)"				,""			,"default ''"),
			array("poll_list_answer10"				,"varchar(255)"				,""			,"default ''"),
			array("poll_list_date_created"			,"datetime"					,"" 		,"default NULL"),
			array("poll_list_created_by"			,"unsigned integer"			,"NOT NULL"	,"default ''"),
			array("poll_list_status"				,"unsigned small integer"	,"NOT NULL"	,"default '0'"),
			array("poll_list_question"				,"varchar(255)"				,""			,"default ''"),
			 // from here on is not used in the Enterprise version of the code they are here 
			 // so that if a second client is added to the database which is not running a Enterprise Licence
			 // then the table structure is set up to use the same structure as basic poll
			array("poll_list_results_available"		,"unsigned small integer"			,"NOT NULL"	,"default '0'"),
			array("poll_list_number_of_votes"		,"unsigned small integer"			,"NOT NULL"	,"default '0'"),
			array("poll_list_settings_for_votes"	,"unsigned small integer"			,"NOT NULL"	,"default '0'"),
			array("poll_list_display_settings"		,"unsigned small integer"			,"NOT NULL"	,"default '0'"),
			array("poll_list_security_option"		,"unsigned small integer"			,"NOT NULL"	,"default '0'"),
			array("poll_list_msg_already_voted"		,"varchar(255)"				,""			,"default ''"),
			array("poll_list_msg_thankyou"			,"varchar(255)"				,""			,"default ''"),
			array("poll_list_results_on_same_page"	,"unsigned small integer"			,"NOT NULL"	,"default '0'")
		);
		$primary ="poll_list_identifier";
		$tables[count($tables)] = array("poll_list", $fields, $primary);
		/**
		* Table structure for table 'group_access'
		*/
		$fields = array(
			array("poll_info_identifier"	,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("poll_info_client"		,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("poll_info_user"			,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("poll_info_date_voted"	,"datetime"			,"NOT NULL"	,"default ''"),
			array("poll_info_answer"		,"varchar(30)"		,"NOT NULL"	,"default ''"),
			array("poll_info_ip_address"	,"varchar(15)"		,"NOT NULL"	,"default ''"),
			array("poll_info_session_id"	,"varchar(32)"		,"NOT NULL"	,"default ''")
		);
		$primary ="";
		$tables[count($tables)] = array("poll_info", $fields, $primary);
		/**
		* Table structure for table 'poll_group'
		*/
		$fields = array(
			array("pg_identifier"			,"unsigned integer"			,"NOT NULL"	,"auto_increment"),
			array("pg_client"				,"unsigned integer"			,"NOT NULL"	,"default '0'"),
			array("pg_label"				,"varchar(255)"				,"NOT NULL"	,"default ''"),
			array("pg_display_option"		,"unsigned integer"			,"NOT NULL"	,"default '0'"),
			array("pg_created_by"			,"unsigned integer"			,"NOT NULL"	,"default '0'"),
			array("pg_date_created"			,"datetime"					,"NOT NULL"	,"default ''"),
			array("pg_results_available"	,"unsigned small integer"	,"NOT NULL"	,"default '0'"),
			array("pg_number_of_votes"		,"unsigned small integer"	,"NOT NULL"	,"default '0'"),
			array("pg_display_settings"		,"unsigned small integer"	,"NOT NULL"	,"default '0'"),
			array("pg_security_option"		,"unsigned small integer"	,"NOT NULL"	,"default '0'"),
			array("pg_msg_already_voted"	,"varchar(255)"				,""			,"default ''"),
			array("pg_msg_thankyou"			,"varchar(255)"				,""			,"default ''"),
			array("pg_results_on_same_page"	,"unsigned small integer"	,"NOT NULL"	,"default '0'"),
			array("pg_results_settings"		,"unsigned small integer"	,"NOT NULL"	,"default '0'"),
			array("pg_all_locations"		,"unsigned small integer"	,"NOT NULL"	,"default '0'"),
			array("pg_status"				,"unsigned small integer"	,"NOT NULL"	,"default '0'"),
			array("pg_set_inheritance"		,"unsigned small integer"	,"NOT NULL"	,"default '0'")
		);
		$primary ="pg_identifier";
		$tables[count($tables)] = array("poll_group", $fields, $primary);
		/**
		* Table structure for table 'poll_group_list' relationship between group and polls
		*/
		$fields = array(
			array("pgl_identifier"		,"unsigned integer"	,"NOT NULL"	,"auto_increment"),
			array("pgl_client"			,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("pgl_group"			,"unsigned integer"	,"NOT NULL"	,"default '0'"),
			array("pgl_poll"			,"unsigned integer"	,"NOT NULL"	,"default '0'")
		);
		$primary ="pgl_identifier";
		$tables[count($tables)] = array("poll_group_list", $fields, $primary);
		return $tables;
	}
}
?>